﻿@model QsdRenderModel
@{
    var QSDItem = Model.CurrentItem;
    var itemname = Model.ItemName;
    var exts = (string[])TempData["FileExts"];//        var extx = new string[] { ".png", ".jpg", ".jpeg", ".gif" };
    var PreviewOnly = (bool)TempData["PreviewOnly"];    //ViewBag.ForceEdit != true && "True".Equals(Request["PreviewOnly"], StringComparison.CurrentCultureIgnoreCase);
}
<div class="attachfield">
    @if (!PreviewOnly)
    {
        <input name="@itemname" type="file" onchange="fileInputCheck(this,0.8);" />
    }
    @if (!string.IsNullOrEmpty(QSDItem.UserValue))
    {
        @Html.Hidden(itemname + ".keep", QSDItem.UserValue)
                            
        var ext = System.IO.Path.GetExtension(QSDItem.UserValue).ToLower();
        <table>
            <tr>
                <td>
                    @if (exts.Contains(ext))
                    {
                        <br />
                        <a class="imagefield-view" target="_blank" href="@(Url.Action("Img", "Recuper", new { ID = QSDItem.UserValue, _newpage = "true" }))">
                            <img src="@(Url.Action("Img", "Recuper", new { ID = QSDItem.UserValue, Preview = true }))" />
                        </a>}
                    else
                    {
                        <br />
                        <a target="_blank" href="@(Url.Action("Img", "Recuper", new { ID = QSDItem.UserValue, _newpage = "true", AttType = "Att" }))">
                            查看附件 </a>}
                </td>
                <td>
                    @if (!PreviewOnly && SiteUser.MainRoleName == "Doctor" && QSDItem.QizSession.QizSubject.SubQizSubjects.Count > 0)
                    {
                        <span>根据此附件补录化验单：</span><ul>
                            @foreach (var subsub in QSDItem.QizSession.QizSubject.SubQizSubjects)
                            {
                                <li>@Html.ActionLink("补录  [" + subsub.Title + "] 从属指标库", "QizSessionEdit", new { ID = string.Empty, RefAttID = QSDItem.ID, SubjectID = subsub.ID }, new { target = "_blank" })</li>
                                    
                            }
                        </ul>
                    }
                </td>
            </tr>
        </table>
    }
</div>
